# -*- coding: utf-8 -*-
"""
------------------------------------------------------------------------------
    File Name:  analyse_predict_result
    Author   :  wanwei1029
    Date     :  2018-10-22
    Desc     :
------------------------------------------------------------------------------
"""
import codecs
import os
import gcc_omcp_utils as utils


MODEL_DIR = utils.BASE_DIR


def analyse_predict_in_model(file_name):
    with codecs.open(file_name, 'r', encoding="utf-8") as f:
        total_yes = 0
        total_no = 0
        for line in f:
            splits = line.split(",")
            if len(splits) != 3:
                print(len(splits))
                print("error input:{0}".format(line))
                continue
            if splits[1].strip() == splits[2].strip():
                # print("yes")
                total_yes += 1
            else:
                # print("no")
                total_no += 1
        print("total_yes is {0}, total_no is {1}".format(total_yes, total_no))
        print(total_yes/(total_yes+total_no))


def analyse_predict(file_name):
    with codecs.open(file_name, 'r', encoding="utf-8") as f:
        for line in f:
            splits = line.split("\t")
            if len(splits) != 5:
                print(len(splits))
                print("error input:{0}".format(line))
                continue
            print(splits[0])
            print(splits[4])


def demo(file_name):
    """
    """
    analyse_predict_in_model(file_name)


if __name__ == '__main__':
    test_method = "demo"
    if test_method == "demo":
        demo(os.path.join(MODEL_DIR, "y_test.pred"))
